﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BGM_Project_Expense_Change.aspx.cs" Inherits="KPIS.GERP.GBMS.APP_UI.Form.BGM_Project_Expense_Change" %>

<%@ Register src="../Controls/Combo/SourceCombo.ascx" tagname="SourceCombo" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <title><asp:Literal runat="Server" id="litTitle"/></title>
</head>
<body>
    <form id="form1" runat="server">
        <link rel="StyleSheet" href="../../Styles/StyleSheet.css" type="text/css" />
        
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager> 
        
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None"  Transparency="100"> 
        </telerik:RadAjaxLoadingPanel>

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="cbSource">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="cbSource" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="gridExpense" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lbOldAmount" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lbNewAmount" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="cbExpenseGroup" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lblException" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cbExpenseGroup">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="cbExpenseGroup" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="gridExpense" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lbOldAmount" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lbNewAmount" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="gridExpense">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="gridExpense" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="lbNewAmount" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cbExpense">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="cbExpense" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="PanelInv" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="PanelInv">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="PanelInv" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>    
                
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function isNumberKey(event) 
                {
                    var charCode = (event.which) ? event.which : event.keyCode
                    if(charCode > 31 && (charCode < 48 || charCode > 57)){
                        return false;
                    }
                    return true;
                }

                function onTextChange(sender) {
                    if (sender.get_value() == "") {
                        sender.set_text("");
                    }
                }
            </script>
        </telerik:RadCodeBlock>

        <div class="bigModuleFull900">
            <div class="bigModuleBottom900">
                <div class="defaultFont" style="height: 450px">
                    <div class="header-grid">
                        <asp:Panel ID="pnControl" runat="server" style="padding: 5px; font-family: 'Segoe UI'; font-size: 13px; font-weight: normal;">
                            <asp:Panel ID="pnButton" runat="server">
                                <table cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td align="left">
                                            <ul class="treeview-list">
                                                <li class="treeview-item" style="border: none">
                                                    <asp:LinkButton ID="AddNew" runat="server" CssClass="LinkButton" 
                                                        onclick="AddNew_Click"><img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/AddRecord.gif" />&nbsp;&nbsp;เพิ่มค่าใช้จ่ายใหม่</asp:LinkButton>
                                                </li>
                                                <li class="treeview-item">
                                                    <asp:LinkButton ID="Update" runat="server" CssClass="LinkButton"
                                                        onclick="Update_Click"><img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cmd_Save.gif" />&nbsp;&nbsp;บันทึกที่แก้ไข</asp:LinkButton>
                                                </li>
                                                <li class="treeview-item">
                                                    <asp:LinkButton ID="Delete" runat="server" CssClass="LinkButton" 
                                                        OnClientClick="javascript:return confirm('ยืนยันการลบข้อมูลที่เลือก')" 
                                                        onclick="Delete_Click"><img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Delete.gif" />&nbsp;&nbsp;ลบค่าใช้จ่าย</asp:LinkButton>
                                                </li>
                                                <li class="treeview-item">
                                                    <asp:Label ID="lbError" runat="server" Text="จำนวนวงเงินก่อนปรับและหลังปรับต้องเท่ากันเสมอ" Visible="false" ForeColor="Red"></asp:Label>
                                                    <asp:Label ID="lbError2" runat="server" Text="จำนวนวงเงินที่กรอกจะต้องไม่ติดลบ" Visible="false" ForeColor="Red"></asp:Label>
                                                </li>
                                            </ul>
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                            <asp:Panel ID="pnAddNew" runat="server" Visible="false">
                                <table>
                                    <tr>
                                        <td style="color: #0066FF; font-weight: bold">
                                            เพิ่มค่าใช้จ่าย
                                        </td>
                                        <td>
                                            <telerik:RadComboBox runat="server" ID="cbExpense" DataTextField="bgm_exp_name" AutoPostBack="true"
                                                DataValueField="bgm_exp_seq" Filter="Contains" Width="500px" OnSelectedIndexChanged="cbExpense_SelectedIndexChanged">
                                            </telerik:RadComboBox>
                                        </td>
                                    </tr>
                                </table>
                                <asp:Panel ID="PanelInv" runat="server" BorderColor="#003399" width="570px"
                                    BorderStyle="Solid" BorderWidth="2px" style="margin-top: 10px; margin-bottom: 10px">
                                    <div class="DivInfo">
                                        <table>
                                            <tr>
                                                <td width="110px">
                                                    รายการพัสดุ :
                                                </td>
                                                <td>
                                                    <telerik:RadComboBox ID="ddlResourceSubGroup" runat="server"
                                                        DataTextField="icm_res_item_name" DataValueField="icm_res_item_seq"
                                                        Width="400px" />&nbsp;*
                                                </td>
                                            </tr>
                                        </table>
                                        <table>
                                            <tr>
                                                <td width="110px">
                                                    จำนวนหน่วย :</td>
                                                <td>
                                                    <telerik:RadNumericTextBox ID="txtUnitQty" runat="server" MinValue="0" 
                                                        AutoPostBack="true" OnTextChanged="txtUnitQty_TextChanged"  />&nbsp;*
                                                </td>
                                            </tr>
                                        </table>
                                        <table>
                                            <tr>
                                                <td width="110px">
                                                    จำนวนเงินต่อหน่วย :
                                                </td>
                                                <td>
                                                    <telerik:RadNumericTextBox ID="txtUnitPrice" runat="server" MinValue="0" 
                                                        AutoPostBack="true" OnTextChanged="txtUnitPrice_TextChanged" />
                                                </td>
                                                <td>
                                                    &nbsp;บาท *
                                                </td>
                                            </tr>
                                        </table>
                                        <table>
                                            <tr>
                                                <td width="110px">
                                                    รวม :
                                                </td>
                                                <td>
                                                    <telerik:RadNumericTextBox ID="txtAmount" runat="server" MinValue="0"  />
                                                </td>
                                                <td>
                                                    &nbsp;บาท *
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </asp:Panel>
                                <table>
                                    <tr>
                                        <td>
                                            &nbsp;&nbsp;
                                            <asp:LinkButton ID="Insert" runat="server" CssClass="LinkButton" onclick="Insert_Click">
                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cmd_Save.gif" />&nbsp;&nbsp;บันทึก
                                            </asp:LinkButton>&nbsp;&nbsp;
                                            <asp:LinkButton ID="Cancel" runat="server" CssClass="LinkButton" onclick="Cancel_Click">
                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cancel.gif" />&nbsp;&nbsp;ยกเลิก
                                            </asp:LinkButton>&nbsp;&nbsp;
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                        </asp:Panel>
                    </div>
                    <table style="margin-left: 20px" width="800px">
                        <tr>
                            <td valign="top" style="padding-top: 20px">
                                แหล่งเงิน :
                            </td>
                            <td valign="top" style="padding-top: 20px">
                                <telerik:RadComboBox runat="server" ID="cbSource" AutoPostBack="true"
                                    DataTextField="text" DataValueField="value" Width="250px" 
                                    onselectedindexchanged="cbSource_SelectedIndexChanged">
                                </telerik:RadComboBox>
                            </td>
                            <td rowspan="2">
                                <fieldset id="fsSummary" style="text-align: left;" >
                                    <legend style="color: #0000FF">
                                        สรุป
                                    </legend>
                                    <table width="400px">                                    
                                        <tr>
                                            <td width="100px">
                                                วงเงินก่อนปรับ
                                            </td>
                                            <td align="right">
                                                <asp:Label ID="lbOldAmount" runat="server" ForeColor="Blue" />
                                            </td>
                                            <td width="20px">
                                                บาท
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="100px">
                                                วงเงินหลังปรับ
                                            </td>
                                            <td align="right">
                                                <asp:Label ID="lbNewAmount" runat="server" ForeColor="Red" />
                                            </td>
                                            <td width="20px">
                                                บาท
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3" style="color: #FF0000">
                                                * จำนวนวงเงินก่อนปรับและหลังปรับต้องเท่ากันเสมอ
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                                งบรายจ่าย :
                            </td>
                            <td valign="top">
                                <telerik:RadComboBox runat="server" ID="cbExpenseGroup" AutoPostBack="true"
                                    DataTextField="Name" DataValueField="Sequence" Width="250px" 
                                    onselectedindexchanged="cbExpenseGroup_SelectedIndexChanged" >
                                </telerik:RadComboBox>
                                <asp:Label ID="lblException" runat="server" Text="ย้ายข้ามงบรายจ่ายได้" ForeColor="Red" Visible="false" />
                            </td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td colspan="2">
                                <asp:Panel ID="pnGridExpense" runat="server" width="800px" Height="300px" ScrollBars="Auto">
                                    <asp:Label ID="lbProjectID" runat="server" Visible="false"></asp:Label>
                                    <table cellpadding="0" cellspacing="0" >
                                        <tr>
                                            <td>
                                                <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="gridExpense" runat="server" AllowFilteringByColumn="True" 
                                                    Font-Names="Segoe UI" Font-Size="13px"
                                                    AllowMultiRowSelection="false" AutoGenerateColumns="False"
                                                    GridLines="None" MasterTableView-GridLines="None" Width="780px" 
                                                    onneeddatasource="gridExpense_NeedDataSource" ><%-- OnItemDataBound="gridExpense_ItemDataBound"--%>
                                                    <mastertableview commanditemdisplay="None" datakeynames="bgm_proj_exp_seq" grouploadmode="Client"
                                                        NoDetailRecordsText="... ไม่มีข้อมูล ..." GroupsDefaultExpanded="true">
                                                        <GroupByExpressions>
                                                            <telerik:GridGroupByExpression>
                                                                <GroupByFields>
                                                                    <telerik:GridGroupByField FieldName="upper_bgm_exp_seq" SortOrder="Ascending" />
                                                                </GroupByFields>
                                                                <SelectFields>
                                                                    <telerik:GridGroupByField FieldName="upper_bgm_exp_name" HeaderText="รายการค่าใช้จ่าย" />
                                                                </SelectFields>
                                                            </telerik:GridGroupByExpression>
                                                        </GroupByExpressions>
                                                        <Columns>
                                                            <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="25px">
                                                            </telerik:GridClientSelectColumn>
                                                            
                                                            <telerik:GridTemplateColumn visible="false" HeaderStyle-HorizontalAlign="Center"
                                                                HeaderText="รหัสค่าใช้จ่าย" ItemStyle-HorizontalAlign="Left"> 
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lbExpSeq" runat="server" Text='<%# Eval("bgm_exp_seq") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                            </telerik:GridTemplateColumn> 
                                                            <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                                                CurrentFilterFunction="Contains" DataField="bgm_exp_name" 
                                                                FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                                                HeaderText="ค่าใช้จ่าย" ShowFilterIcon="false" UniqueName="bgm_exp_name">
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                            </telerik:GridBoundColumn>
                                                            <%--<telerik:GridBoundColumn AutoPostBackOnFilter="true" ItemStyle-HorizontalAlign="Right"
                                                                CurrentFilterFunction="Contains" DataField="remain_total_amount" 
                                                                FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" DataFormatString="{0:N2}"
                                                                HeaderText="คงเหลือ(บาท)" ShowFilterIcon="false" UniqueName="remain_total_amount">
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                            </telerik:GridBoundColumn>--%>
                                                            <telerik:GridTemplateColumn HeaderStyle-Width="120px" ShowFilterIcon="false" AllowFiltering="false" UniqueName="total_amount"
                                                                HeaderStyle-HorizontalAlign="Center" HeaderText="คงเหลือ(บาท)" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="120px"> 
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lbTotalAmount" runat="server" Text='<%# Eval("total_amount", "{0:n2}") %>' Visible="false"></asp:Label>
                                                                    <telerik:RadNumericTextBox ID="txtTotalAmount" runat="server" Width="110px"
                                                                        Text='<%# Eval("total_amount") %>' CssClass="RadNumericTextBox"
                                                                        AutoPostBack="true" OnTextChanged="txtTotalAmount_TextChanged"></telerik:RadNumericTextBox>
                                                                </ItemTemplate>
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridBoundColumn visible="false" UniqueName="bgm_proj_exp_seq" DataField="bgm_proj_exp_seq" 
                                                                HeaderStyle-HorizontalAlign="Center" HeaderText="รหัสค่าใช้จ่าย" ItemStyle-HorizontalAlign="Left">
                                                            </telerik:GridBoundColumn>
                                                        </Columns>
                                                        <%--<groupbyexpressions>
                                                            <telerik:GridGroupByExpression>
                                                                <groupbyfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_grp_seq" HeaderText="" />
                                                                </groupbyfields>
                                                                <selectfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_grp_name" HeaderText="งบรายจ่าย : " HeaderValueSeparator="" />
                                                                </selectfields>
                                                            </telerik:GridGroupByExpression>
                                                            <telerik:GridGroupByExpression>
                                                                <groupbyfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_seq_3" HeaderText="" />
                                                                </groupbyfields>
                                                                <selectfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_name_3" HeaderText="หมวดค่าใช้จ่าย : " HeaderValueSeparator="" />
                                                                </selectfields>
                                                            </telerik:GridGroupByExpression>
                                                            <telerik:GridGroupByExpression>
                                                                <groupbyfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_seq_2" HeaderText="" />
                                                                </groupbyfields>
                                                                <selectfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_name_2" HeaderText="รายการรายจ่าย : " HeaderValueSeparator="" />
                                                                </selectfields>
                                                            </telerik:GridGroupByExpression>
                                                            <telerik:GridGroupByExpression>
                                                                <groupbyfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_seq_1" HeaderText="" />
                                                                </groupbyfields>
                                                                <selectfields>
                                                                    <telerik:GridGroupByField FieldName="bgm_exp_name_1" HeaderText="รายการรายจ่าย : " HeaderValueSeparator="" />
                                                                </selectfields>
                                                            </telerik:GridGroupByExpression>
                                                        </groupbyexpressions>--%>
                                                    </mastertableview>
                                                <clientsettings EnableRowHoverStyle="true">
                                                    <clientevents />
                                                        <selecting AllowRowSelect="True" />
                                                    </clientsettings>
                                                </telerik:RadGrid>
                                            </td>
                                        </tr>
                                    </table>
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <%--<telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" OnAjaxUpdate="RadToolTipManager1_AjaxUpdate"
            RelativeTo="Element" HideEvent="LeaveToolTip" ShowEvent="OnClick" 
            RenderInPageRoot="True" Skin="Vista" Width="850px" Height="370px">
        </telerik:RadToolTipManager>--%>
    </form>
</body>
</html>
